<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			window.onload=function(){
				//获取多个元素
				var divArr = document.getElementsByTagName("div");//会返回一个数组
				for (let i = 0; i < divArr.length; i++) {
				
					divArr[i].style.background = i%2==0?"red":"green";
				}
				//类名获取元素
				var divArr1 = document 
				
			}
		</script>
	</head>
	<body>
		<div>divcontent</div>
		<div>divcontent</div>
		<div>divcontent</div>
		<span class="123" >
			
		</span>
	</body>
</html>